//BNB OMP maxsat
//$Id: maxsat_bnb_omp.cpp 667 2011-02-26 18:59:32Z Oleg.Bulychov $
#include "stdafx.h"

#include "projects/maxsat/maxsat.h"
#include "projects/maxsat/sa/maxsat_sa.h"
#include "projects/maxsat/bnb/maxsat_bnb.h"

#include "src/heo/include/transmit_array.h"
#include "src/heo/include/transmit_dynamic_bit_array.h"
#include "src/heo/include/console_color.h"

#include "solvers/sa/sa_omp.h"
#include "solvers/bnb/bnb_omp.h"
#include "solvers/hybrids/weak_hybrid.h"


#include "src/heo/include/run_omp.h"


//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
void Mem_Panic(size_t cbRequired, size_t* pcbAvailable)
{
    //TODO fix me...
    std::cout << "mem panic: " << cbRequired << " bytes required" << lf;
    if (pcbAvailable)
        std::cout << "but " << *pcbAvailable << " available" << lf;

}
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
typedef MaxSat_Problem  TProblem;
typedef MaxSat_Solution TSolution;
typedef MaxSat_Config   TConfig;

typedef Environment<TProblem, TSolution, TConfig>   TEnvironment;

typedef BNB_Traits<TEnvironment,
    MaxSat_BnB_Task,
    MaxSat_BnB_Params,
    MaxSat_BnB_Predictor,
    std::less<MaxSat_Solution::TCostType>
> TTraits1;
//typedef BNB<TTraits1>                 TSolver1;
typedef BNB_OMP<TTraits1>                 TSolver1;

typedef SA_Traits<TEnvironment> TTraits0;
typedef SA_OMP<TTraits0>                  TSolver0;

int main(int argc, char* argv[])
{
    //:TODO mem from args, if no mem - report & quit
    int np = omp_get_max_threads();
    VERIFY_(lite_allocator::construct(np, 48));//:memory in MB per thread
    VERIFY_(big_allocator::construct(np, 24));//:memory in MB per thread

    //int r = Run_OMP< weak_hybrid<TSolver0, TSolver1, check_point_omp> >(argc, argv);
    int r = Run_OMP< TSolver1 >(argc, argv);

#if(MEM_STAT > 0)
    std::cout << lf << "__________" << lf;
    big_allocator::report(std::cout);
    std::cout << "==========" << lf;
    lite_allocator::report(std::cout);
#if defined(_MSC_VER)
    extern void If_Debug_Press_Enter();
    If_Debug_Press_Enter();
#endif
#endif

    big_allocator::destruct();
    lite_allocator::destruct();
    page_allocator::destruct();

    return r;
}
//EOF!
